function Ball(x, y, r) {
			this.x = x;
			this.y = y;
			this.r = r;
			var zuoyou = Math.random() > 0.5 ? -1 : 1;
			this.vx = parseInt(Math.random() * 15 + 5) * zuoyou;
			zuoyou = Math.random() > 0.5 ? -1 : 1;
//									 this.vy=0;
//									 this.vx=0;
			this.vy = parseInt(Math.random() * 15 + 5) * zuoyou;
			this.color = "rgb(" + parseInt(Math.random() * 256) + "," + parseInt(Math.random() * 256) + "," + parseInt(Math.random() * 256) + ")";
		}
		var canvas = document.getElementById("canvas");
		var cxt = canvas.getContext("2d");
		var balls = [];
		var time;
		getTime();
		setInterval(function() {
			cxt.translate(canvas.width * -0.8, 0);
			canvas.height = document.documentElement.clientHeight - 3;//每100毫秒获取一次浏览器高度
			canvas.width = document.documentElement.clientWidth;
			cxt.clearRect(0, 0, canvas.width, canvas.height);
			updatetime();
			getTime()
		}, 100)

		function drawNum(arrNum) {
			var ballR = parseInt(canvas.width * 0.008);
			for(var i = 0; i < arrNum.length; i++) {
				for(var k = 0; k < arrNum[i].length; k++) {
					if(arrNum[i][k] == 1) {
						cxt.beginPath();
						cxt.arc(k * ballR * 2 + parseInt(canvas.width*0.1), i * ballR * 2 + parseInt(canvas.height*0.1), ballR, 0, 2 * Math.PI);
						cxt.fill();
					}
				}
			}
		}

		function getTime() {
			time = new Date;
			var hh = time.getHours();
			var mm = time.getMinutes();
			var ss = time.getSeconds();
			var timearr = [];
			timearr.push(parseInt(hh / 10));
			timearr.push(hh % 10);
			timearr.push(10);
			timearr.push(parseInt(mm / 10));
			timearr.push(mm % 10);
			timearr.push(10);
			timearr.push(parseInt(ss / 10));
			timearr.push(ss % 10);
			drawTime(timearr)
		}

		function updatetime() {
			var date = new Date;
			var hh = date.getHours();
			var mm = date.getMinutes();
			var ss = date.getSeconds();

			if(ss != time.getSeconds()) {
				//添加爆破小球
				var s2 = parseInt(canvas.width * 0.675);
				var s1 = parseInt(canvas.width * 0.556);
				var m2 = parseInt(canvas.width * 0.396);
				var m1 = parseInt(canvas.width * 0.279);
				var h2 = parseInt(canvas.width * 0.118);
				if(ss % 10 != time.getSeconds() % 10) {
					addBall(s2, 10, 10, time.getSeconds() % 10)
				}
				if(parseInt(ss / 10) != parseInt(time.getSeconds() / 10)) {
					addBall(s1, 10, 10, parseInt(time.getSeconds() / 10))
				}
				if(mm % 10 != time.getMinutes() % 10) {
					addBall(m2, 10, 10, time.getMinutes() % 10)
				}
				if(parseInt(mm / 10) != parseInt(time.getMinutes() / 10)) {
					addBall(m1, 10, 10, parseInt(time.getMinutes() / 10))
				}
				if(hh % 10 != time.getHours() % 10) {
					addBall(h2, 10, 10, time.getHours() % 10)
				}
				if(parseInt(hh / 10) != parseInt(time.getHours() / 10)) {
					addBall(0, 10, 10, parseInt(time.getHours() / 10))
				}
			}
			drawBalls();
		}

		function drawBalls() {
			var count = 0; //区域内小球个数
			for(var i = 0; i < balls.length; i++) {
				cxt.beginPath();
				balls[i].x += balls[i].vx;
				balls[i].y += balls[i].vy;
				balls[i].vy += 9.8;

				if(balls[i].y >= canvas.height - balls[i].r) {
					balls[i].y = canvas.height - balls[i].r;
					balls[i].vy = -0.6 * balls[i].vy
				}
				cxt.arc(balls[i].x, balls[i].y, parseInt(canvas.width * 0.0083), 0, 2 * Math.PI)
				cxt.fillStyle = balls[i].color;
				cxt.fill();

				//判断可视区域的小球，将可视区域的小球移到数组前面
				if(balls[i].x > -balls[i].r && balls[i].x < canvas.width) {
					balls[count++] = balls[i];
				}
			}
			while(count < balls.length) {
				balls.pop();
			}
		}

		function addBall(x, y, r, num) {
			var nums = numbers[num];
			for(var i = 0; i < nums.length; i++) {
				for(var k = 0; k < nums[i].length; k++) {
					if(nums[i][k] == 1) {
						balls.push(new Ball(x + k * 2 * r, y + i * 2 * r, r));
					}
				}
			}
		}

		function drawTime(timearr) {
			var grd = cxt.createLinearGradient(0, 0, 450, 50);
			grd.addColorStop(0.1, "#FF0000");
			grd.addColorStop(0.5, "yellow");
			grd.addColorStop(1, "green");
			cxt.fillStyle = grd;
			for(var i = 0; i < timearr.length; i++) {
				drawNum(numbers[timearr[i]]);
				if(i == 2 || i == 5) {
					cxt.translate(canvas.width * 0.06, 0);
				} else if(i == 1 || i == 4) {
					cxt.translate(canvas.width * 0.1, 0);
				} else {
					cxt.translate(canvas.width * 0.12, 0);
				}
			}
		}